<?php

defined('SYSPATH') OR die('No direct access allowed.');

class User_Controller extends Controller {

	public function __construct()
	{
		parent::__construct();
		$this->user_model = new User_Model;	
		$this->role_model = new Role_Model;
	}
	
	public function index()
	{				
		if(!parent::_authenticate()) {
			return;
		}
		parent::_loadContent("Daftar pengguna", 'user_content');
		$this->view->content->user = $this->user_model;
		$this->view->content->roles = $this->role_model;
		$this->view->render(TRUE);
	}
	
    public function add_user() {
        $this->user_model->insert_user(array('username' => $this->input->post('username'), 'password' => md5($this->input->post('password')), 'ID_role' => $this->input->post('ID_role')));
        url::redirect('user');
    }
}